package com.ruoyi.supplier.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.supplier.domain.vo.purchase.PurchaseDetailVo;
import com.ruoyi.supplier.domain.vo.purchase.PurchaseLackVo;
import com.ruoyi.supplier.domain.vo.purchase.PurchaseOutVo;
import com.ruoyi.supplier.domain.vo.purchase.PurchasePageQueryVo;
import com.ruoyi.supplier.manager.PurchaseManager;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 采购单控制器
 * 前端访问路由地址为:/supplier/purchase
 *
 * @author ruoyi
 * @date 2023-09-18
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/pick")
public class PurchasePickController extends BaseController {

    @Autowired
    private PurchaseManager purchaseManager;

    /**
     * 新增采购单
     */
    @PostMapping("/addOut")
    public R<Void> create(@Validated @RequestBody PurchaseLackVo lackVo) {
        purchaseManager.lack(lackVo);
        return R.ok();
    }

    /**
     * 查询采购单列表
     */
    @PostMapping("/outList")
    public TableDataInfo<PurchaseOutVo> outList(PurchasePageQueryVo pageQuery) {
        return purchaseManager.queryOutPageList(pageQuery);
    }

    /**
     * 查询采购单列表
     */
    @GetMapping("/detail")
    public R<PurchaseDetailVo> detail(Integer purchaseId) {
        return R.ok(purchaseManager.outDetail(purchaseId));
    }

    /**
     * 缺货单发
     */
    @GetMapping("/outDetail")
    public R<PurchaseDetailVo> outDetail(Integer purchaseId) {
        return R.ok(purchaseManager.outDetail(purchaseId));
    }

}
